<template>
	<view class="">
		<view class="scroll_header"></view>
		<scroll-view scroll-y="true" :style="{height: scrollHeight}">
			<view class="mt-5" v-if="u_loadmore">
				<u-loadmore status="loading" icon-type="circle" />
			</view>
			<view v-else>
				<view class="" v-for="(items,indexs) in record_list" :key="indexs">
					<view class="p-3 font-weight">{{items.month.substr(6,7)==month?'本':items.month.substr(6,7)}}月</view>
					<view class="bg-white btt pl-4 pr-3 " v-for="(item,index) in items.data" :key="index">
						<view class="py-4 bt border-bottom" @click="with_detail(item)">
							<view class="d-flex j-sb">
								<view class="">提现({{item.withdraw_way=="bank"?"银行卡":'会员余额'}})</view>
								<view class="font-weight">{{item.amount}}</view>
							</view>
							<view class="d-flex j-sb">
								<view class="text-999">{{item.formatted_add_time}}</view>
								<view class="text-999">{{item.label_status}}</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				record_list:"", // 商家提现申请记录
				scrollHeight:0,// 屏幕高度
				date: new Date().toISOString().slice(0, 10),
				month:"", // 月份
				u_loadmore:true, // 加载中
			}
		},
		onReady() {
			let _this=this
			uni.getSystemInfo({
				success(resu) {
					const query = uni.createSelectorQuery()
					query.select('.scroll_header').boundingClientRect()
					query.exec(function(res) {
						_this.scrollHeight = resu.windowHeight - res[0].bottom+ 'px';
					})
				}
			})
		},
		methods:{
			with_detail(item){
				uni.navigateTo({
					url:'/pagesA/store/store-withdraw-details?log_id='+item.log_id
				})
			}
		},
		onLoad() {
			var date = new Date();
			this.month=date .getMonth()+1; //获取当前月份(0-11,0代表1月)
			this.$H.post("v2/store/withdraw/record").then(res=>{
				let arr=res.data
				
				let map = {}
				let dest = []
				arr.forEach(v=>{
					if(!map[v.month]){
						dest.push({
						    month: v.month,
						    data: [v]
						});
						map[v.month] = v;
					}else {
						dest.forEach(i=>{
							if (i.month.substr(6,7) == v.month.substr(6,7)) {
							    i.data.push(v);
							}
						})
				    }
				})
				this.u_loadmore=false 
				this.record_list=dest
			})
		}
	}
</script>

<style>
	/* .btt .bt:last-child::after{
		border: none;
	} */
</style>
